﻿namespace Digitalmes.Domain.Mes;

/// <summary>
/// 生产用料。
/// </summary>
/// <remarks>
/// 记录产品使用的关键物料和批次料。
/// </remarks>
[SugarTable("prod_material_consume", "产品用料表")]
[SugarIndex("index_prod_material_consume_sn", nameof(Sn), OrderByType.Asc)]
[SugarIndex("index_prod_material_consume_barcode", nameof(Barcode), OrderByType.Asc)]
public class ProdMaterialConsume : EntityBaseId
{
    /// <summary>
    /// SN
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "SN", Length = 64)]
    public string? Sn { get; set; }

    /// <summary>
    /// 产线 Id。
    /// </summary>
    public long LineId { get; set; }

    /// <summary>
    /// 产线编号
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "产线编号", Length = 32)]
    public string? LineCode { get; set; }

    /// <summary>
    /// 工位 Id。
    /// </summary>
    public long OpId { get; set; }

    /// <summary>
    /// 工位编号
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "工位编号", Length = 32)]
    public string? OpCode { get; set; }

    /// <summary>
    /// 工序 Id。
    /// </summary>
    public long ProcId { get; set; }

    /// <summary>
    /// 工序编号
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "工序编号", Length = 32)]
    public string? ProcCode { get; set; }

    /// <summary>
    /// 上料步序,0 表示没有步序。
    /// </summary>
    [SugarColumn(ColumnDescription = "上料步序")]
    public int Step { get; set; }

    /// <summary>
    /// 物料代码
    /// </summary>
    [SugarColumn(ColumnDescription = "物料编号", Length = 64)]
    public string? MaterialCode { get; set; }

    /// <summary>
    /// 物料条码
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "物料条码", Length = 64)]
    public string? Barcode { get; set; }

    /// <summary>
    /// 上料时间
    /// </summary>
    [SugarColumn(ColumnDescription = "上料时间")]
    public DateTime FeedingTime { get; set; }

    /// <summary>
    /// 是否已解绑
    /// </summary>
    /// <remarks>解绑后物料可再次使用</remarks>
    [SugarColumn(ColumnDescription = "是否解绑")]
    public bool IsUnbound { get; set; }

    /// <summary>
    /// 修改时间
    /// </summary>
    [SugarColumn(ColumnDescription = "修改时间")]
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// 修改人
    /// </summary>
    [SugarColumn(ColumnDescription = "修改人", Length = 64)]
    public string? UpdateUser { get; set; }
}
